#include<iostream>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10;
LL n, t, a, b;
int main()
{
	cin >> n >> t;
	LL temp = 0;
	LL ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		if (temp >= a) {
			a = temp + 1;
		}
		temp = a + b - 1;
		ans += b;
		if (temp >= t) {
			ans -= temp - t;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}